#!/bin/bash
if [ "$TARGET" == "" ] ; then
	if [ -d /var/lib/dpkg ] ; then
		export TARGET=debian
	elif [ -d /var/lib/inary ] ; then
		export TARGET=inary
	elif [ -d /var/lib/pacman ] ; then
		export TARGET=arch
	else
		export TARGET=default
	fi
fi
set +e
if [ "$TARGET" == "debian" ] ; then
	if [ "$arch" == "" ] ; then
		[ "$(uname -m)" == "x86_64" ] && arch="amd64"  || true
		[ "$(uname -m)" == "i686" ] && arch="i386" || true
		[ "$(uname -m)" == "aarch64" ] && arch="arm64"  || true
		[ "$(uname -m)" == "armhf" ] && arch="arm"  || true
	fi
elif [ "$TARGET" == "inary" ] ; then
	if [ "$arch" == "" ] ; then
		arch="$(uname -m)"
	fi
elif [ "$TARGET" == "arch" ] ; then
	if [ "$arch" == "" ] ; then
		arch="$(uname -m)"
	fi
fi
set -e
info "Target=$TARGET"
info "Arch=$arch"
